package com.bf.exception;

import com.bf.web.R;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;



/**
 * 自定义异常处理
 */
@Slf4j
@RestControllerAdvice
public class BfExceptionHandler {

    @ExceptionHandler(BfException.class)
    public R<Void> handleHyException(BfException e, HttpServletRequest request) {
        String requestURI = request.getRequestURI();
        log.error("请求地址'{}',发生未知异常.", requestURI, e);
        return R.fail(e.getMessage());
    }

}
